package com.haste.controller;

import com.haste.pojo.CommonResult;
import com.haste.pojo.Payment;
import com.haste.service.PaymentFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName:FeignOrderController
 * @Description:
 * @Author:Haste
 * @Date:2021/2/7 14:41
 */
@RestController
@Slf4j
public class FeignOrderController {
    @Resource
    private PaymentFeignService paymentFeignService;
    @GetMapping("/consumer/feign/list")
    public CommonResult list(){
        CommonResult list = paymentFeignService.list();
        if (list != null){
            return new CommonResult(200,"查询成功",list.getData());
        }
        return null;
    }

    @GetMapping("/consumer/feign/detail/{id}")
    public CommonResult<Payment>  detail(@PathVariable("id") Long id){
        CommonResult<Payment> detail = paymentFeignService.detail(id);
        if (detail != null){
            return new CommonResult(200,"yes",detail.getData());
        }
        return null;
    }

    @GetMapping("/consumer/feign/timeout")
    public String timeout(){
        return paymentFeignService.paymentFeignTimeout();
    }
}
